package com.dein.admin.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.dein.admin.dao.AdminDao;
import com.dein.admin.model.Admin;
import com.dein.admin.service.AdminService;

@Service("adminService")
public class AdminServiceImpl implements AdminService {
	
	protected AdminDao adminDao;
	
	@Autowired
	@Qualifier("adminDao")
	public void setAdminDao(AdminDao adminDao){
		this.adminDao = adminDao;
	}

	@Override
	public Long adminLogin(String adminName, String adminPw) {
		try {
			return adminDao.adminLogin(adminName, adminPw);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public boolean adminExist(String adminName) {
		try {
			if(adminDao.adminExist(adminName)>0)
				return false;
			else 
				return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public Admin getAdminById(Long adminId) {
		try {
			return adminDao.getAdminById(adminId);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
